/**
 * 
 */
package com.mbengue.corp.apr.ra.util;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * @author MMB11447
 *
 */
public class HibernateListener implements ServletContextListener {
  /* (non-Javadoc)
   * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
   */
  @Override
  public void contextDestroyed(ServletContextEvent arg0) {
    HibernateUtil.getSessionFactory().close(); // Free all resources
  }

  /* (non-Javadoc)
   * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
   */
  @Override
  public void contextInitialized(ServletContextEvent arg0) {
    HibernateUtil.getSessionFactory(); // Just call the static initializer of that class    
  }
}
